import Vue from 'vue'

const AlertConstructor = Vue.extend(require('./alert.vue').default) // 直接将Vue组件作为Vue.extend的参数

let nId = 1


const Confirm = (title,content,confirmSure) => {

const ConfirmInstance = new AlertConstructor({
    data: {
      title: title,
      content: content,
      type:2
    },
    methods:{
    	confirmSure:confirmSure?confirmSure:()=>console.log()//确定方法
    }
}) // 实例化一个带有content内容的Alert

//ConfirmInstance.id = id
ConfirmInstance.vm = ConfirmInstance.$mount() // 挂载但是并未插入dom，是一个完整的Vue实例
ConfirmInstance.vm.isshow = true
ConfirmInstance.dom = ConfirmInstance.vm.$el
document.body.appendChild(ConfirmInstance.dom) // 将dom插入body
//AlertInstance.dom.style.zIndex = nId + 1001 // 后插入的Notice组件z-index加一，保证能盖在之前的上面
return ConfirmInstance.vm
}

export default {
  install: Vue => {
    Vue.prototype.$confirm = Confirm // 将Alert组件暴露出去，并挂载在Vue的prototype上
  }
}